﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace DHQGHN.PM2.Controllers
{
    public static class CommonData
    {
        public const string AppCode = "TKTHDS.PM2";
        public static readonly string AppName = "PM Quản lý kế hoạch";
        public static string GetListId(int[] ids)
        {
            return GetListId("Danh sách id: ", ";", ids);
        }

        public static string GetListId(string[] ids)
        {
            List<int> data = new List<int>();
            int result = 0;
            for (int i = 0; i < ids.Length; i++)
            {
                if (int.TryParse(ids[i], out result))
                {
                    data.Add(result);
                }
            }

            return GetListId("Danh sách id: ", ";", data.ToArray());
        }

        public static string GetListId(string title, string splitter, int[] ids)
        {
            StringBuilder idList = new StringBuilder();
            int len = ids.Length;
            idList.Append(title);
            for (int i = 0; i < len; i++)
            {
                idList.Append(ids[i]).Append(splitter);
            }
            string result = idList.ToString().TrimEnd(splitter.ToCharArray());

            return result;
        }
    }
}